# Written by winter 2003/11/20

SHELL = /bin/sh

CC = gcc

AR = ar

TARGET = otc chkholiday rescue tail

SRCS = main.c tse.c uutil.c hhash.c tpool.c cpool.c

CTAGS = ctags -x > tags

OBJ= uutil.o tse.o hhash.o tpool.o cpool.o

all:  clean libotc.a tags $(TARGET) cls

libotc.a: $(OBJ) 
	$(AR) rvu $@ $(OBJ)
	ranlib $@
	
tags:	$(SRCS)
	$(CTAGS) $(SRCS) 
		
	 	
CFLAGS = -O1 -L../LIB  -I/usr/local/include/mysql 

LIBS = -O3 -fomit-frame-pointer -L../LIB  -I../include  -L./ -lotc -lsocket -lnsl -lrt -lpthread -lmysqlclient -lm

NFLAGS = -O2 -Wall -g -DLOG -I/usr/local/include/mysql -lpthread -lsocket -lnsl

MY_PROGRAM_DEP = main.o

FUNC_DEP = main.c 

otc: $(MY_PROGRAM_DEP) 
	$(CC) -o tse $? $(LIBS)
	
stockd: stockd.c
	$(CC) stockd.c -o stockd.e  $(NFLAGS)
	
chkholiday: chkholiday.o 
	$(CC) -o $@ $? uutil.o $(LIBS)
	
rescue: rescue.o
	$(CC) -o $@ $? uutil.o hhash.o $(LIBS)

tail: tail.o
	$(CC) -o $@ $? uutil.o hhash.o $(LIBS)

object: $(FUNC_DEP)
	$(CC) -c $*.c

cls:
	@rm -f *.o
	@rm -f *~ DEADJOE core.* *.core 
	@rm -f *.bak

clean:  
	@rm -f $(TARGET)